import request from '@/api/ajax'
 
export function getAllEmps(pn,pageSize) {
    return request({
        url: '/ssm_demo/emps',
        method: 'get',
        params:{
            pn,
            pageSize,
        }
    })
}
export function getAllDepts() {
    return request({
        url: '/ssm_demo/depts',
        method: 'get',
    })
}
export function saveEpm(employee) {
    return request({
        url: '/ssm_demo/saveEmp',
        method: 'post',
        params:employee
    })
}
export function checkNameSame(empName) {
    return request({
        url: '/ssm_demo/checkEmpName',
        method: 'get',
        params:{
            empName
        }
    })
}
export function updateEpm(employee) {
    return request({
        url: '/ssm_demo/emp/'+employee.empId,
        method: 'put',
        params:{
            email:employee.email,
            gender:employee.gender,
            dId:employee.dId
        }
    })
}
export function deleteEmpById(employee) {
    return request({
        url: '/ssm_demo/emp/'+employee.empId,
        method: 'delete'
    })
}
export function deleteEmps(employees) {
    var del_idstr = "";
    employees.forEach(emp => {
        del_idstr += emp.empId + "-";
    });
    del_idstr = del_idstr.substring(0,del_idstr.lastIndexOf("-"));
    return request({
        url: '/ssm_demo/emp/'+del_idstr,
        method: 'delete'
    })
}

